package cn.itsource.system.controllor;

import cn.itsource.system.domain.Logininfo;
import cn.itsource.system.service.LogininfoService;
import cn.itsource.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginInfoController {

    @Autowired
    private LogininfoService logininfoService;

    @PostMapping
   public AjaxResult login(@RequestBody Logininfo logininfo){

        try {
            return AjaxResult.ok(logininfoService.login(logininfo));
        } catch (RuntimeException e) {
            e.printStackTrace();
            return AjaxResult.fail();
        }catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.fail("网络繁忙，请稍后再试！");
        }
   }
}
